home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_pow_ewebammo_m.cog < prev    next >
Text File  |  1998-02-25  |  3KB  |  143 lines

  1. # Jedi Knight MOTHS Cog Script
  2. #
  3. # POW_ENERGY.COG
  4. #
  5. # POWERUP Script - Energy
  6. #
  7. # [YB, CYW, SRS]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10.  
  11.  
  12. symbols
  13.  
  14. template    explode=+small_exp             local
  15.  
  16. thing       powerup                          local
  17. thing       player                           local
  18. thing       sender                           local
  19.  
  20. int         bin=92                           local
  21. sound       pickupsnd=nrgpu1.wav             local
  22. sound       respawnsnd=Activate01.wav        local
  23. flex        amount                           local
  24.  
  25. int         bin_contents=0                   local
  26. int         autoselect_weapon=-1             local
  27. int         damage                           local
  28.  
  29. message     created
  30. message     damaged
  31. message     touched
  32. message     taken
  33. message     respawn
  34. message     timer
  35.  
  36. end
  37.  
  38. # ========================================================================================
  39.  
  40. code
  41.  
  42.  
  43. created:
  44.    SetThingUserData(GetSenderRef(), 30);     // set the initial user data (i.e. "health")
  45.    Return;
  46.  
  47. # ........................................................................................
  48.  
  49. touched:
  50.    player = GetSourceRef();
  51.  
  52.    if (GetThingType(player) == 10)  // Can only be taken by players.
  53.    {
  54.       amount = GetInv(player, bin);
  55.  
  56.       if ((amount < GetInvMax(player, bin)) || IsMulti())
  57.       {
  58.          powerup = GetSenderRef();
  59.          TakeItem(powerup, player);
  60.       }
  61.    }
  62.  
  63.    Return;
  64.  
  65. # ........................................................................................
  66.  
  67. damaged:
  68.    sender = GetSenderRef();
  69.  
  70.    // only take damage 33% of the time
  71.    if(rand() < 0.33)
  72.       return;
  73.  
  74.    // If it's already dead, don't allow any more damage.
  75.    if (!GetThingUserData (sender))
  76.       return;
  77.  
  78.    damage = GetParam (0);
  79.  
  80.    // see if this will cause the explosion
  81.    if (GetThingUserData (sender) <= damage)
  82.    {
  83.       SetThingUserData(sender, 0);
  84.  
  85.       // timer for base explosion
  86.       SetTimerEx ((Rand () * 0.5), sender, 1, 0);
  87.    }
  88.    else
  89.    {
  90.       SetThingUserData(sender, GetThingUserData (sender) - damage);
  91.    }
  92.  
  93.    ReturnEx (0);
  94.    return;
  95.  
  96. # ........................................................................................
  97.  
  98. taken:
  99.    powerup = GetSenderRef();
  100.  
  101. // // If the object has been destroyed, don't award it to the player.
  102. //   if (!GetThingUserData (powerup))
  103. //    return;
  104.  
  105.    player = GetSourceRef();
  106.  
  107.    // Print("Energy Cells");
  108.    jkPrintUNIString(player, bin);
  109.  
  110.    // Do effects.
  111.    PlaySoundLocal(pickupsnd, 1, 0, 0);
  112.    AddDynamicTint(player, 0.0, 0.0, 0.2);
  113.  
  114.    // store the old bin contents
  115.    bin_contents = GetInv(player, bin);
  116.  
  117.    // Increment powerup amount.
  118.    ChangeInv(player, bin, 100.0);
  119.  
  120.    return;
  121.  
  122. # ........................................................................................
  123.  
  124. respawn:
  125.    SetThingUserData(GetSenderRef(), 30);     // set the initial user data (i.e. "health")
  126.    PlaySoundThingLocal(respawnsnd, GetSenderRef(), 0.6, 5.0, 10.0, 0);
  127.  
  128.    return;
  129.  
  130. # ........................................................................................
  131.  
  132. timer:
  133.    sender = GetSenderId ();
  134.  
  135.    powerup = CreateThingNR (explode, sender);
  136.  
  137.    TakeItem(sender, -1);
  138.    return;
  139.  
  140. end
  141.  
  142.  
  143.